package com.qvtu.management.mapper;

import com.qvtu.management.pojo.Dept;
import com.qvtu.management.pojo.Emp;
import org.apache.ibatis.annotations.*;

import java.time.LocalDate;
import java.util.List;

/**
 * 员工管理
 */
@Mapper
public interface EmpMapper {

    @Select("select count(*) from emp ")
    public long count();

    //分页查询获取列表数据
//    @parm start 开始位置 @param pageSize 每页显示条数
//    @Select("select * from emp limit #{start},#{pageSize}")
//    public List<Emp> page(@Param("start") Integer start, @Param("pageSize") Integer pageSize);

    //按条件查询员工

    List<Emp> list(@Param("page") Integer page, @Param("pageSize") Integer pageSize, @Param("name") String name,
                   @Param("gender") Short gender,
                   @Param("begin") LocalDate begin,
                   @Param("end") LocalDate end);

    // 根据条件计算总记录数
    long countWithConditions(@Param("name") String name, @Param("gender") Short gender,
                             @Param("begin") LocalDate begin, @Param("end") LocalDate end);
    void delete(List<Integer> ids);

    @Insert("insert into emp(username,name,gender,image,job,entrydate,dept_id,create_time,update_time) " +
            "values(#{username},#{name},#{gender},#{image},#{job},#{entrydate},#{deptId},#{createTime},#{updateTime}) ")
    void insert(Emp emp);

    @Select("select * from emp where id = #{id}")
    Emp getById(Integer id);

//    @Update("update emp set username=#{username},password=#{password},name=#{name},gender=#{gender}," +
//            "image=#{image},job=#{job},entrydate=#{entrydate},dept_id=#{deptId},update_time=#{updateTime} where id = #{id}")
    void update(Emp emp);

// Integer id   @Select("select * from emp")
//    public List<Emp> list();
    
}
